using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes.DomainAttributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Enums;
using System.Collections.Generic;
using System.ComponentModel;

namespace Baci.ArcGIS._DataManagementTools._GeodatabaseAdministration
{
    /// <summary>
    /// <para>Rebuild Indexes</para>
    /// <para>Rebuild existing attribute or spatial indexes in enterprise geodatabases.  Indexes  can also be rebuilt on  states and state_lineage geodatabase system tables and the delta tables of datasets that are registered to participate in traditional versioning. Out-of-date indexes can lead to poor query performance.</para>
    /// <para>重新构建企业级地理数据库中的现有属性或空间索引。 还可以在状态上重新构建索引，并state_lineage地理数据库系统表以及注册为参与传统版本化的数据集的增量表。过时的索引可能会导致查询性能不佳。</para>
    /// </summary>    
    [DisplayName("Rebuild Indexes")]
    public class RebuildIndexes : AbstractGPProcess
    {
        /// <summary>
        /// 无参构造
        /// </summary>
        public RebuildIndexes()
        {

        }

        /// <summary>
        /// 有参构造
        /// </summary>
        /// <param name="_input_database">
        /// <para>Input Database Connection</para>
        /// <para>The connection (.sde file) to the database or geodatabase that contains the data for which you want to rebuild indexes.</para>
        /// <para>与包含要为其重新构建索引的数据的数据库或地理数据库的连接（.sde 文件）。</para>
        /// </param>
        /// <param name="_include_system">
        /// <para>Include System Tables</para>
        /// <para><xdoc>
        ///   <para>Indicates whether indexes will be rebuilt on the states and state lineages tables.</para>
        ///   <para>You must connect as the geodatabase administrator for this option to be activated.</para>
        ///   <para>This option only applies to geodatabases. If you connect to a database, this option is disabled.</para>
        ///   <bulletList>
        ///     <bullet_item>Unchecked—Indexes will not be rebuilt on the states and state lineages table. This is the default.</bullet_item><para/>
        ///     <bullet_item>Checked—Indexes will be rebuilt on the states and state lineages tables.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指示是否要在状态和状态世系表上重建索引。</para>
        ///   <para>您必须以地理数据库管理员身份进行连接才能激活此选项。</para>
        ///   <para>此选项仅适用于地理数据库。如果连接到数据库，则此选项处于禁用状态。</para>
        ///   <bulletList>
        ///     <bullet_item>未选中 - 不会在状态和状态世系表上重建索引。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>选中 - 将在状态和状态世系表上重建索引。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// </param>
        public RebuildIndexes(object _input_database, _include_system_value _include_system)
        {
            this._input_database = _input_database;
            this._include_system = _include_system;
        }
        public override string ToolboxName => "Data Management Tools";

        public override string ToolName => "Rebuild Indexes";

        public override string CallName => "management.RebuildIndexes";

        public override List<string> AcceptEnvironments => ["workspace"];

        public override object[] ParameterInfo => [_input_database, _include_system.GetGPValue(), _in_datasets, _delta_only.GetGPValue(), _out_workspace];

        /// <summary>
        /// <para>Input Database Connection</para>
        /// <para>The connection (.sde file) to the database or geodatabase that contains the data for which you want to rebuild indexes.</para>
        /// <para>与包含要为其重新构建索引的数据的数据库或地理数据库的连接（.sde 文件）。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input Database Connection")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _input_database { get; set; }


        /// <summary>
        /// <para>Include System Tables</para>
        /// <para><xdoc>
        ///   <para>Indicates whether indexes will be rebuilt on the states and state lineages tables.</para>
        ///   <para>You must connect as the geodatabase administrator for this option to be activated.</para>
        ///   <para>This option only applies to geodatabases. If you connect to a database, this option is disabled.</para>
        ///   <bulletList>
        ///     <bullet_item>Unchecked—Indexes will not be rebuilt on the states and state lineages table. This is the default.</bullet_item><para/>
        ///     <bullet_item>Checked—Indexes will be rebuilt on the states and state lineages tables.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指示是否要在状态和状态世系表上重建索引。</para>
        ///   <para>您必须以地理数据库管理员身份进行连接才能激活此选项。</para>
        ///   <para>此选项仅适用于地理数据库。如果连接到数据库，则此选项处于禁用状态。</para>
        ///   <bulletList>
        ///     <bullet_item>未选中 - 不会在状态和状态世系表上重建索引。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>选中 - 将在状态和状态世系表上重建索引。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Include System Tables")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public _include_system_value _include_system { get; set; }

        public enum _include_system_value
        {
            /// <summary>
            /// <para>SYSTEM</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("SYSTEM")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>NO_SYSTEM</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("NO_SYSTEM")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Datasets to Rebuild Indexes For</para>
        /// <para>Names of the datasets that will have their indexes rebuilt. Only datasets that are owned by the connected user are displayed.</para>
        /// <para>将重新生成其索引的数据集的名称。仅显示连接用户拥有的数据集。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Datasets to Rebuild Indexes For")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public List<object> _in_datasets { get; set; } = null;


        /// <summary>
        /// <para>Rebuild Delta Tables Only</para>
        /// <para><xdoc>
        ///   <para>Indicates whether indexes will be rebuilt only on the delta tables of the selected datasets. This option will be unavailable if there are no datasets selected in the list of input datasets.</para>
        ///   <para>This option only applies to geodatabases. If you connect to a database, this option is disabled.</para>
        ///   <bulletList>
        ///     <bullet_item>Checked—Indexes will only be rebuilt for the delta tables of the selected datasets. This option can be used for cases where the business tables for the selected datasets are not updated often and there are a high volume of edits in the delta tables. This is the default.</bullet_item><para/>
        ///     <bullet_item>Unchecked—Indexes will be rebuilt on all indexes for the selected datasets. This includes spatial indexes as well as user-created attribute indexes and any geodatabase-maintained indexes for the dataset.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指示是否仅在所选数据集的增量表上重新生成索引。如果输入数据集列表中未选择数据集，则此选项将不可用。</para>
        ///   <para>此选项仅适用于地理数据库。如果连接到数据库，则此选项处于禁用状态。</para>
        ///   <bulletList>
        ///     <bullet_item>选中 - 仅为所选数据集的增量表重新构建索引。此选项可用于所选数据集的业务表不经常更新且增量表中存在大量编辑的情况。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>未选中—将在所选数据集的所有索引上重新构建索引。这包括空间索引、用户创建的属性索引以及任何地理数据库维护的数据集索引。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Rebuild Delta Tables Only")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _delta_only_value _delta_only { get; set; } = _delta_only_value._true;

        public enum _delta_only_value
        {
            /// <summary>
            /// <para>ONLY_DELTAS</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("ONLY_DELTAS")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>ALL</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("ALL")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Updated Workspace</para>
        /// <para></para>
        /// <para></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Updated Workspace")]
        [Description("")]
        [Option(OptionTypeEnum.derived)]
        public object _out_workspace { get; set; }


        public RebuildIndexes SetEnv(object workspace = null)
        {
            base.SetEnv(workspace: workspace);
            return this;
        }

    }

}